<template>
    <div class="home">
        <userHead active="sousuo" :showAction="true"></userHead>
        <div class="home_main">
         
            <div class="hm_right">
                
                <div class="hmr_content">
                    
                    <div class="hmrc_body">
						<el-table :data="tableData" ref="multipleTable"  @selection-change="handleSelectionChange"  stripe border style="width: 100%">
							
							<el-table-column
								type="selection"
								width="30">
							</el-table-column>
							<el-table-column label="职位名称">
								
							</el-table-column>
							<el-table-column label="公司名称">
							
							</el-table-column>
							<el-table-column label="部门名称">
								
							</el-table-column>
							<el-table-column label="职位年薪">
							
							</el-table-column>
							
							<el-table-column label="工作地点">
								
							</el-table-column>

                            <el-table-column label="发布时间">
								
							</el-table-column>
                            <el-table-column label="渠道" >
								
							</el-table-column>

							<el-table-column label="是否投递" >
								
							</el-table-column>

                           
							
							
							<el-table-column label="操作" >
								
							</el-table-column>
						

						</el-table>
					</div>

                </div>


            </div>
        </div>
        <div class="post_bottom">
            <post-footer-main-vue></post-footer-main-vue>
        </div>

    </div>
</template>

<script>
// @ is an alias to /src
import userHead from '@/components/userHead.vue';
import homeapi from '@/api/api.js'
import userImg from '@/assets/imgs/ai_logo.jpg'
import postFooterMainVue from '@/components/postFooterMain.vue';
import biographicalNotesAdd from '@/views/biographicalNotes/add.vue'
import { refresh } from 'less';
import until from '@/api/until';
export default {
    name: 'HomeView',
    data() {
        return {
            companyInfo: {},
            input: "",
            value: "",
            tableData: [],
            totalInfo: {},

            showDel: true,
            showTag: true,
            showPost: true,
            showResume: true,
            showTotal: true,
            showMoney: true,

            dictInfo: {},
            companyList: [],
            haveAdd: false,
            haveEdit: false,
            selectPost: [],
            postForm: {},
            reword: '',
            name: "",
            status: '1',
            showEidt: false,

            userReme: {},
            userMainReme: {},
            userSumeContent: {},
            userImg: userImg
        }
    },
    components: {
        userHead, postFooterMainVue, biographicalNotesAdd
    },
    mounted() {
        this.getSumeContent();
        this.getDictList();

        this.getLitterSume();

    },
    beforeDestroy() {
        until.setCookie("isEdit", '')
    },
    methods: {
        //获取极简简历
        async getLitterSume() {
            let data = await homeapi.getLitterSume();
            if (data.code == 200) {
                this.userReme = data.result
            }
            // if(data.)
        },
        //获取完整简历
        async getMainSume() {
            let data = await homeapi.getMainSume();
            if (data.code == 200) {

                data.result.resumeSkills.resumeSkillLanguageList.map(res => {
                    res.showEdit = false;
                })

                data.result.resumeEducations.map(res => {
                    res.showEdg = false;
                })
                data.result.resumeDetails.map(res => {
                    res.showMore = false;
                    res.isNow = false

                    if (res.workingEnd == "9999-12-31") {
                        res.isNow = true;
                    }
                    res.resumePostList.map(json => {
                        json.isNow = false
                        json.showChild = false
                        if (json.workingEnd == '9999-12-31') {
                            json.isNow = true
                        }
                    })

                })

                this.userMainReme = data.result;

                setTimeout(() => {
                    if (this.$refs.biographical && this.$refs.biographical.workplace.length > 0) {
                        this.$refs.biographical.getForm(this.userSumeContent);
                    }

                })




            }
        },
        //获取编辑简历
        async getSumeContent() {
            let data = await homeapi.getSumeContent();
            if (data.code == 200) {
                data.result.resumeDetailList.map((res, index) => {
                    res.isNow = false
                    res.resumePostList.map((json, jsonindex) => {
                        json.postWorkPlace = [];
                        json.isNow = false
                        json.showChild = false

                    })

                })
                this.userSumeContent = data.result;

                this.getMainSume();

            }
        },

        //更新头像
        async updateResumeImg(form) {
            let data = await homeapi.updateResumeImg(form)
            if (data.code == 200) {
                this.$toast("更改成功")
                this.getSumeContent();
                this.getLitterSume();

            }
        },


        showEditReme() {
            until.setCookie("isEdit", true)
            this.getSumeContent();
            this.showEidt = true;
        },

        handleSelectionChange(val) {
            this.selectPost = val;
        },
        //获取数据字典
        async getDictList() {
            let data = await homeapi.getDictList();
            if (data.code == 200) {
                this.dictInfo = data.result
            }
        },
        //保存简历
        async saveSume(form) {

            let data = await homeapi.saveSume(form);
            if (data.code == 200) {
                this.getSumeContent();
                this.updateUserInfo(form)

            }
        },

        //更新基本信息
        async updateUserInfo(userSume) {
            console.log(this.userMainReme)

            let form = {
                birthday: this.userMainReme.birthday,
                email: this.userMainReme.email,
                idCard: this.userMainReme.idCard,
                img: this.userMainReme.img,
                name: this.userMainReme.name,
                postRank: this.userMainReme.postRank,
                sex: this.userMainReme.sex,
                wechat: this.userMainReme.wechat,
            }
            let data = await homeapi.updateUserInfo(form)
            if (data.code == 200) {

            }
        },

        //刷新简历
        async refreshReme() {
            let data = await homeapi.refreshReme({})
            if (data.code == 200) {
                this.getLitterSume();
            }
        },
        //更新简历图片
        async changeFile(e) {
            if (e.target.files.length > 0) {
                let file = e.target.files[0];
                var formData = new FormData();

                formData.append("file", file);
                let data = await homeapi.uploadFile(formData);

                if (data.code == 200) {
                    this.updateResumeImg({ img: data.result.path })
                    // this.form.postImgUrl = data.result.url;
                    // this.form.postImg = data.result.path;
                    // console.log(this.form);
                }
            }
        },
    }
}
</script>
<style>
.el-table th.el-table__cell {
    background: #ebebeb;
}

.el-table thead {
    color: #333333;
    font-weight: bold;
}

.el-table--border .el-table__cell,
.el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
    border-right: 1px solid #ddd;
}

.el-table .el-table__cell {
    padding: 0px !important;
}

.el-table__row .el-table__cell {
    padding: 10px 0 !important;
}
</style>
<style scoped>
.home_main {
    width: 100%;

    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0 16px;
    box-sizing: border-box;
    padding-bottom: 60px;
}

.hm_left {
    width: 180px;
    min-width: 180px;


    border-radius: 0px 0px 0px 0px;

    display: inline-block;
    background: #FFFFFF;
    margin-top: 15px;
    padding-bottom: 30px;
}

.hml_main {
    width: 100%;

    background: #FFFFFF;

    padding: 0 20px;
    padding-bottom: 16px;
    ;
    box-sizing: border-box;

}

.hm_right {
    flex: 1;
   
    height: 100%;


}

.hml_div {
    width: 100%;
    display: inline-block;
    margin-top: 16px;
    cursor: pointer;
}

.hmld_head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 13px;
    color: #333333;
    font-weight: bold;
}

.hmld_left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 12px;
    margin-left: 8px;
}

.hmld_left .iconfont {
    font-size: 14px;
    margin-left: 8px;
    color: #999999;
}

.hml_content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    line-height: 18px;
    padding-left: 20px;
    box-sizing: border-box;
    margin-top: 6px;
}

.hml_content span:first-child {
    font-size: 12px;
    color: #06c;
}

.hml_content span:last-child {
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
}

.hmr_head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 16px;
}

.hmrh_div {
    flex: 1;
    height: 40px;
    border-radius: 4px;
    background: #FFFFFF;
    border-radius: 0px 0px 0px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 14px;
    color: #333333;
    font-weight: bold;
    line-height: 32px;
    margin-left: 16px;
    cursor: pointer;
}



.hmr_content {
    width: 100%;

    margin-top: 16px;
    background: #FFFFFF;
    display: inline-block;

    height: calc(100vh - 165px);
    overflow: auto;
   
}

.hmrc_head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 9px;
    padding: 0 32px;
    box-sizing: border-box;
}

.hmrch_left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.select_div {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-left: 16px;
    font-size: 16px;
}

.select_div_label {
    margin-right: 8px;
}

.hmrch_right {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 15px;
    padding-left: 15px;
    box-sizing: border-box;
}

.hmrchr_div {
    width: 72px;
    height: 34px;
    background: #F5792A;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #FFFFFF;
    margin-right: 16px;
    cursor: pointer;
}

.hmrc_body {
    width: 100%;

    box-sizing: border-box;

}

.reword {
    width: 100%;

    background: #FFFFFF;
    height:100%;
    overflow: auto;
}

.rw_title {
    width: 180px;
    height: 44px;
    background: #F2F2F2;
    border-radius: 0px 0px 0px 0px;
    border: 1px solid #E6E6E6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #3D3D3D;
    font-weight: bold;
}

.rw_list {
    width: 100%;
    display: inline-block;
    padding-left: 10px;
    box-sizing: border-box;
}

.rwl_main {
    width: 100%;
    display: inline-block;
}

.rwl_title {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 10px;
    cursor: pointer;
}

.rwlt_icon i {
    font-size: 14px;
    color: #333333;
}

.rwlt_name {
    font-size: 13px;
    color: #333333;
    font-weight: bold;
    margin-left: 4px;
}

.rwl_list {
    width: 100%;
    display: inline-block;
}

.rwll_div {
    font-size: 12px;
    line-height: 18px;
    color: #06c;
    padding-left: 30px;
    box-sizing: border-box;
    margin-top: 6px;
    cursor: pointer;
}

.rwll_div:hover {
    color: #F5792A;
}

.hmrc_botoom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hmrch_left_main {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #333333;
    margin-top: 15px;
    margin-right: 15px;
}



.rwlt_btn {
    width: 72px;
    height: 26px;
    background: #F5792A;
    border-radius: 0px 0px 0px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #FFFFFF;
    margin-left: 28px;
    border-radius: 4px;
}

.rwl_title i {
    font-size: 16px;
    margin-left: 10px;
    color: #333333;
}

.border_div {
    width: 100%;
    height: 15px;
    background: #f8f8f8;
}

.hmrchl_div {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.center_div {
    text-align: center;
}

.need_input {
    height: 40px;
    border: 1px solid #DCDFE6;
    text-align: center;
    font-size: 14px;
    border-radius: 2px;
    width: 100%;
}

.post_bottom {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
}

.iconmd {
    display: flex;
}

.selecthmth span {
    color: #06c;
}

.selecthmth span:last-child {
    color: #06c;
}
.select_hmrh{
    background: #F5792A;
    color: #ffff;
}
</style>
<style>
.el-table-column--selection .cell {
    padding: 0px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.el-table th.el-table__cell>.cell {

    padding-left: 8px;
    padding-right: 5px;
}

.el-table th.el-table__cell.is-leaf .el-checkbox {
    margin-left: 7px;
}

.memberphoto img {
    width: 108px;
    height: 108px;
}

.vitaelink {
    margin-right: 10px;
}

.memberphoto {
    position: relative;
}

</style>
